package com.yonyougov.devops.cruxcisupport.button;

import com.yonyougov.devops.cruxcisupport.button.vo.ButtonByMenuIdRespVo;
import com.yonyougov.devops.cruxcisupport.button.vo.CurrentUserButtonByMenuCodeDto;
import com.yonyougov.devops.cruxcisupport.button.vo.NoLinkButtonByRoleIdDto;
import com.yonyougov.devops.cruxcisupport.button.vo.NoLinkButtonByRoleIdVo;
import com.yonyougov.devops.fwc.core.dao.impl.BaseDaoImpl;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * t_button数据层实现
 */
@Repository
public class ButtonDaoImpl extends BaseDaoImpl<ButtonEntity, BigInteger> implements ButtonDao {

    //<!--用户自定义代码开始-->
    private SqlSessionTemplate sqlSessionTemplate;

    ButtonDaoImpl(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    @Override
    public List<NoLinkButtonByRoleIdVo> findNoLinkButtonByRoleId(NoLinkButtonByRoleIdDto noLinkButtonByRoleIdDto) {
        String statement = ButtonEntity.class.getName() + "Mapper.findAllButtonNoLinkByRoleId";
        return sqlSessionTemplate.selectList(statement, noLinkButtonByRoleIdDto);
    }

    @Override
    public int countNoLinkButtonByRoleId(NoLinkButtonByRoleIdDto noLinkButtonByRoleIdDto) {
        String statement = ButtonEntity.class.getName() + "Mapper.countByAllButtonNoLinkByRoleId";
        return sqlSessionTemplate.selectOne(statement, noLinkButtonByRoleIdDto);
    }

    @Override
    public List<ButtonByMenuIdRespVo> findButtonByMenuCode(CurrentUserButtonByMenuCodeDto currentUserButtonByMenuIdDto) {
        String statement = ButtonEntity.class.getName() + "Mapper.findButtonByMenuCode";
        return sqlSessionTemplate.selectList(statement, currentUserButtonByMenuIdDto);
    }


    //<!--用户自定义代码结束-->
}
